package com.example.app.controller;

import com.example.app.entity.Track;
import com.example.app.entity.TrackPoint;
import com.example.app.service.TrackService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/tracks")
public class TrackController {

    @Resource
    private TrackService trackService;

    @PostMapping("/upload")
    public Track uploadTrack(@RequestBody Track track) {
        return trackService.saveTrack(track);
    }

    @PostMapping("/point")
    public TrackPoint uploadPoint(@RequestBody TrackPoint point) {
        return trackService.saveTrackPoint(point);
    }

    @GetMapping("/user/{userId}")
    public List<Track> getUserTracks(@PathVariable Long userId) {
        return trackService.findByUserId(userId);
    }
}
